home *** CD-ROM | disk | FTP | other *** search
/ Minami 78 / MINAMI78.iso / Extra / winamp53.exe / $R0 / Winamp Modern / scripts / videoavs.m < prev    next >
Text File  |  2005-09-15  |  10KB  |  314 lines

  1. #include <lib/std.mi>
  2. #include <lib/config.mi>
  3.  
  4. #define MAIN_ATTRIBS_MGR
  5.  
  6. Function updateVisCmd();
  7. Function updateOpenCloseDirection();
  8.  
  9. // this implements the main app drawer
  10. #include "drawer.m"
  11.  
  12. // this loads the skin config attributes definitions
  13. #include "attribs.m"
  14.  
  15. Global Layout main, shade;
  16. Global Container maincontainer;
  17. Global Group frameGroup, ButtonsVideo,ButtonsVis,ButtonsVideoDetach,ButtonsVisDetach,ButtonsVideoSwitchto,ButtonsVisSwitchto;
  18. Global Button btnOpen,btnClose,btnMaximize,btnRestore, btnVisDetach, btnVideoDetach, btnVisSwitchto, btnVideoSwitchto;
  19. Global Layer resizer,resizerDrawer,OpenCloseHider;
  20. Global GuiObject VideoVisGroup;
  21. Global Int evershown;
  22. Global Int ismaximized;
  23. Global Int lasttotop;
  24.  
  25. //------------------------------------------------------------------------
  26. // script startup
  27. //------------------------------------------------------------------------
  28. System.onScriptLoaded() {
  29.     // init skin attributes for this script
  30.  
  31.     initAttribs();
  32.  
  33.     // bind objects
  34.  
  35.     frameGroup = getScriptGroup();
  36.     btnOpen = frameGroup.findObject("videoavs.open");
  37.     btnClose = frameGroup.findObject("videoavs.close");
  38.     btnMaximize = frameGroup.findObject("button.vid.max");
  39.     btnRestore = frameGroup.findObject("button.vid.restore");
  40.     resizer = frameGroup.findObject("player.main.resizer");
  41.     resizerDrawer = frameGroup.findObject("drawer.resizer");
  42.  
  43.     ButtonsVideo = frameGroup.findObject("buttons.video");
  44.     ButtonsVis = frameGroup.findObject("buttons.vis");
  45.  
  46.     ButtonsVideoDetach = frameGroup.findObject("buttons.video.detach");
  47.     ButtonsVisDetach = frameGroup.findObject("buttons.vis.detach");
  48.     BtnVisDetach = ButtonsVisDetach.findObject("button.vis.detach");
  49.     BtnVideoDetach = ButtonsVideoDetach.findObject("button.vid.detach");
  50.  
  51.     ButtonsVideoSwitchto = frameGroup.findObject("buttons.video.switchto");
  52.     ButtonsVisSwitchto = frameGroup.findObject("buttons.vis.switchto");
  53.  
  54.     BtnVisSwitchto = ButtonsVisSwitchto.findObject("button.vis.Switchto");
  55.     BtnVideoSwitchto = ButtonsVideoSwitchto.findObject("button.vid.Switchto");
  56.  
  57.     OpenCloseHider=frameGroup.findObject("openclosehider");
  58.  
  59.     main = frameGroup.getParentLayout();
  60.     maincontainer = main.getContainer();
  61.     VideoVisGroup = frameGroup.findObject("AVSGroup");
  62.  
  63.     VideoVisGroup.hide();
  64.  
  65.     // bind drawer script attribs to our attribs 
  66.  
  67.     __drawer_directiontop_attrib = drawer_directiontop_attrib;
  68.     __scrolldrawerattrib = scrolldrawerattrib;
  69.     __drawer_directionbypass_attrib = drawer_directionbypass_attrib;
  70.     __vis_detach_attrib = vis_detach_attrib;
  71.     __video_detach_attrib = video_detach_attrib;
  72.  
  73.     // startup drawer script
  74.  
  75.     initDrawer(main, "VideoAVS");
  76.  
  77.     // more init
  78.  
  79.     if (vis_detach_attrib.getData() == "1" && video_detach_attrib.getData() == "1") OpenCloseHider.show();
  80.     else OpenCloseHider.hide();
  81.  
  82.     lasttotop = 0;
  83. }
  84.  
  85. //------------------------------------------------------------------------
  86. // grab a handle to the windowshade layout, can't get it in onScriptLoaded since it doesn't exists yet
  87. // also, first time we are shown, we update the viscmd button's action
  88. //------------------------------------------------------------------------
  89. main.onSetVisible(int show) {
  90.     if (!evershown) {
  91.         evershown = 1;
  92.         if (!shade) {
  93.             shade = maincontainer.getLayout("shade");
  94.         }
  95.         updateVisCmd();
  96.         updateOpenCloseDirection();
  97.     }
  98. }
  99.  
  100. //------------------------------------------------------------------------
  101. // script shutdown
  102. //------------------------------------------------------------------------
  103. System.onScriptUnloading() {
  104.     
  105.     // shutdown the drawer script
  106.  
  107.     shutdownDrawer();
  108. }
  109.  
  110. //------------------------------------------------------------------------
  111. // drawer script backend
  112. //------------------------------------------------------------------------
  113.  
  114. Int getDrawerClosedHeight() {
  115.     return 280; // this is the size of the layout when the drawer is closed
  116. }
  117.  
  118. Int getDefaultDrawerOpenHeight() {
  119.     return 510; // this is the default size of the layout, used when it opens the first time
  120. }
  121.  
  122. // whenever the main window is resized while its drawer is closed, we change the height of the drawer the 
  123. // next time it opens so that video will fit 4:3
  124. Int getDrawerOpenAutoHeight(int layoutwidth) {
  125.     return (layoutwidth-6)*(3/4)+55+270; 
  126. }
  127.  
  128. WindowHolder getVisWindowHolder() {
  129.     WindowHolder wh = getScriptGroup().findObject("myviswnd");
  130.     return wh; // we return our vis windowholder object
  131. }
  132.  
  133. WindowHolder getVideoWindowHolder() {
  134.     WindowHolder wh = getScriptGroup().findObject("myvideownd");
  135.     return wh; // we return our video windowholder object
  136. }
  137.  
  138. //------------------------------------------------------------------------
  139. // optional drawer events
  140. //------------------------------------------------------------------------
  141.  
  142. onDoneOpeningDrawer() {
  143.     // nothing to do
  144. }
  145.  
  146. onDoneClosingDrawer() {
  147.     VideoVisGroup.hide();
  148. }
  149.  
  150. onBeforeOpeningDrawer() {
  151.     resizer.setXmlParam("resize", "bottomright");
  152.     resizerDrawer.setXmlParam("resize", "bottomright");
  153.     btnOpen.hide();
  154.     main.setXmlParam("minimum_h", "380");
  155.  
  156.     VideoVisGroup.show();
  157. }
  158.  
  159. onBeforeClosingDrawer() {
  160.     resizer.setXmlParam("resize", "right");
  161.     resizerDrawer.setXmlParam("resize", "right");
  162.     main.setXmlParam("minimum_h", "280");
  163.     btnOpen.show();
  164. }
  165.  
  166. onShowVis() {
  167.     ButtonsVideo.hide();
  168.     ButtonsVideoDetach.hide();
  169.     ButtonsVideoSwitchto.hide();
  170.     ButtonsVis.show();
  171.     ButtonsVisDetach.show();
  172.     if (video_detach_attrib.getData() == "0") ButtonsVisSwitchto.show();
  173. }
  174.  
  175. onHideVis() {
  176.     ButtonsVis.hide();
  177.     ButtonsVisDetach.hide();
  178.     ButtonsVisSwitchto.hide();
  179. }
  180.  
  181. onShowVideo() {
  182.     ButtonsVis.hide();
  183.     ButtonsVisDetach.hide();
  184.     ButtonsVisSwitchto.hide();
  185.     ButtonsVideo.show();
  186.     ButtonsVideoDetach.show();
  187.     if (vis_detach_attrib.getData() == "0") ButtonsVideoSwitchto.show();
  188. }
  189.  
  190. onHideVideo() {
  191.     ButtonsVideo.hide();
  192.     ButtonsVideoDetach.hide();
  193.     ButtonsVideoSwitchto.hide();
  194. }
  195.  
  196. onDetachVideo() {
  197.     ButtonsVisSwitchto.hide();
  198.     if (vis_detach_attrib.getData() == "1") OpenCloseHider.show();
  199. }
  200.  
  201. onAttachVideo() {
  202.     ButtonsVisSwitchto.show();
  203.     OpenCloseHider.hide();
  204. }
  205.  
  206. onDetachVis() {
  207.     ButtonsVideoSwitchto.hide();
  208.     if (video_detach_attrib.getData() == "1") OpenCloseHider.show();
  209. }
  210.  
  211. onAttachVis() {
  212.     ButtonsVideoSwitchto.show();
  213.     OpenCloseHider.hide();
  214. }
  215.  
  216. onBeforeRestore() {
  217.     btnMaximize.show();
  218.     btnRestore.hide();
  219. }
  220.  
  221. onBeforeMaximize() {
  222.     btnRestore.show();
  223.     btnMaximize.hide();
  224. }
  225.  
  226. onCancelMaximize() {
  227.     btnMaximize.show();
  228.     btnRestore.hide();
  229. }
  230.  
  231. // -----------------------------------------------------------------------
  232. // drawer control
  233. // -----------------------------------------------------------------------
  234.  
  235. btnOpen.onLeftClick() {
  236.     openDrawer();
  237. }
  238.  
  239. btnClose.onLeftClick() {
  240.     closeDrawer();
  241. }
  242.  
  243. btnMaximize.onLeftClick() {
  244.     maximizeWindow();
  245. }
  246.  
  247. btnRestore.onLeftClick() {
  248.     restoreWindow();
  249. }
  250.  
  251. BtnVisDetach.onLeftClick() {
  252.     detachVis();
  253. }
  254.  
  255. BtnVideoDetach.onLeftClick() {
  256.     detachVideo();
  257. }
  258.  
  259. BtnVisSwitchto.onLeftClick() {
  260.     switchToVideo();
  261. }
  262.  
  263. BtnVideoSwitchto.onLeftClick() {
  264.     switchToVis();
  265. }
  266.  
  267. // -----------------------------------------------------------------------
  268. // when the player window is moved on the screen, we should update the up/down arrow for the open/close buttons since the
  269. // drawer may have changed the direction it will open depending on user settings
  270. // -----------------------------------------------------------------------
  271. main.onMove() {
  272.   updateOpenCloseDirection();
  273. }
  274.  
  275. // -----------------------------------------------------------------------
  276. // just invert the images when the direction is to top and restore them otherwise
  277. // -----------------------------------------------------------------------
  278. updateOpenCloseDirection() {
  279.   if (isDrawerToTop()) {
  280.     if (!lasttotop) {
  281.       btnClose.setXmlParam("image", "player.button.videoavs");
  282.       btnClose.setXmlParam("downimage", "player.button.videoavs.pressed");
  283.       btnClose.setXmlParam("hoverImage", "player.button.videoavs.hover");
  284.       btnOpen.setXmlParam("image", "player.button.videoavs.up");
  285.       btnOpen.setXmlParam("downimage", "player.button.videoavs.up.pressed");
  286.       btnOpen.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
  287.       lasttotop = 1;
  288.      }
  289.   } else {
  290.     if (lasttotop) {
  291.       btnOpen.setXmlParam("image", "player.button.videoavs");
  292.       btnOpen.setXmlParam("downimage", "player.button.videoavs.pressed");
  293.       btnOpen.setXmlParam("hoverImage", "player.button.videoavs.hover");
  294.       btnClose.setXmlParam("image", "player.button.videoavs.up");
  295.       btnClose.setXmlParam("downimage", "player.button.videoavs.up.pressed");
  296.       btnClose.setXmlParam("hoverImage", "player.button.videoavs.up.hover");
  297.       lasttotop = 0;
  298.     }
  299.   }
  300. }
  301.  
  302. // -----------------------------------------------------------------------
  303. updateVisCmd() {
  304.     Button btn = getScriptGroup().findObject("button.vis.misc");
  305.     if (btn) {
  306.         if (viscmd_menu_attrib.getData() == "1") {
  307.             btn.setXmlParam("action", "Vis_Menu");
  308.         } else {
  309.             btn.setXmlParam("action", "Vis_Cfg");
  310.         }
  311.     }
  312. }
  313.  
  314.